GCC (GNU C Compiler -> GNU Compiler Collection)
-
Originally, the name was "GNU C Compiler" because it only compiled the C language. Over time, it began to support other languages and was renamed "GNU Compiler Collection".
-
Part of the GNU project; widely used in Linux. Supports multiple languages.
-
License :
-
Open-source GPL.
-
-
Platforms :
-
Windows (via MinGW), Linux, macOS, BSD
-
-
Debugging
-
GDB.
-
-
Minimum requirements :
-
Windows:
-
MinGW.
-
~MSYS2.
-
You don't need MSYS2 to use GCC on Windows. MinGW already provides GCC ready to use.
-
MSYS2 is an additional environment that facilitates installation and package management, but it is not mandatory.
-
-
-
Linux:
-
Just the package.
-
-
-
My version :
-
(2025-06-13) 14.2.0
-
gcc -o main main.c
gcc -o main main.c random.c -lm
MinGW (Minimalist GNU for Windows)
-
It is a set of development tools that allows compiling C, C++, and Fortran code on Windows using the GNU ecosystem (GCC, GDB, Make, etc.), without relying on Microsoft Visual Studio (MSVC).
-
It fits into two main categories:
-
As a Build Tool (providing compilers like
gccandg++). -
As an alternative to MSVC (Microsoft compiler).
-
-
MinGW Features :
-
gccandg++(GNU compilers for C/C++ on Windows). -
make(build tool forMakefile). -
gdb(GNU debugger). -
Standard GNU libraries (glibc, libstdc++).
-
-
UCRT vs MSVCRT :
-
UCRT is available as an alternative to MSVCRT.
-
Unless you are targeting older versions of Windows, UCRT as runtime library is the better choice, as it was written to better support recent Windows versions as well as provide better standards conformance.
-
-
MSYS2 (Minimal SYStem 2)
-
Is a package-based development environment that provides a Unix-like terminal on Windows, along with tools like GCC (MinGW-w64), Make, Git, Python, and a package manager (
pacman, the same as Arch Linux). -
It is an evolution of the old MSYS and Cygwin, but focuses on:
-
Compiling native Windows programs (with MinGW-w64).
-
Offering a Unix-like environment without sacrificing Windows compatibility.
-
Easily managing libraries and dependencies via
pacman.
-
-
MSYS2 has three different "environments," each with a specific purpose:
-
MSYS2
-
Base environment with Bash shell, coreutils (like
ls,grep), andpacmanfor package and script management.
-
-
MinGW-w64 (UCRT/MSVCRT)
-
Compilers to generate native Windows executables.
-
-
CLANG64/CLANG32
-
Versions of Clang/LLVM for Windows.
-
-
-
You choose the environment via the terminal shortcut that opens:
-
MSYS2 Shell (for administration).
-
MinGW-w64 Shell (to compile with GCC).
-
Clang64 Shell (to compile with Clang).
-
-
-
Installation :
pacman -S mingw-w64-x86_64-gcc # Install GCC 64-bit pacman -S mingw-w64-i686-gcc # Install GCC 32-bit
Commands
-
-o-
Sets the name of the output file.
-
-
-std=c11-
Specify Language Standard.
-
C89, C99, C11, C17, etc.
-
-ansi-
Forces compliance with C89/C90.
-
-
-
Compilation :
-
-c-
Compile without linking, creating the object file
.o/.obj.
-
-
-v-
Verbose mode (shows compilation steps).
-
-
-
Linking :
-
-l<name>-
Link with a library.
-
-lm-
Link with the Math Library
libm.-
Needed for functions like
sin(),cos(),sqrt(),pow(), etc.
-
-
-
-lpthread.-
For threads.
-
-
-
-L<path>-
Adds a library directory.
-
-L./lib.
-
-
-static-
Link statically (avoids dynamic dependencies).
-
-
-shared-
Generates a shared library (
.so/.dll).
-
-
-fPIC-
Generates position-independent code (used in shared libs).
-
-
-
Pre-processor / Macro :
-
-I<path>-
Adds an include directory.
-
-I./include.-
Looks for headers in
./include.
-
-
-
-D<macro>-
Defines a macro (ex:
-DDEBUGis equivalent todefine DEBUG).
-
-
-U<macro>-
Undefines a macro.
-
-
-E-
Only preprocesses (outputs
includeanddefineresults).
-
-
-M-
Generates build dependencies (useful for Makefiles).
-
-
-
Debug :
-
-g-
Includes debug symbols (needed for gdb and valgrind ).
-
-
-ggdb-
Optimizes debug symbols for GDB (more detailed than
-g).
-
-
-fsanitize=address-
Detects memory leaks, buffer overflows (AddressSanitizer).
-
-
-fsanitize=undefined-
Detects undefined behavior (UB).
-
-
-fstack-protector-
Protection against stack smashing.
-
-
-fno-stack-protector-
Disables stack overflow protection.
-
-
-
Warnings / Errors :
-
-Wall-
Enable Compilation Warnings.
-
-
-Wextra-
Enables extra warnings beyond
-Wall.
-
-
-Wpedantic-
Enforces strict C standard compliance (complains about GNU extensions).
-
-
-Wno-warning_name-
Disables a specific warning (ex:
-Wno-unused-variable).
-
-
-Werror-
Treat Warning as Errors.
-
-
-
Optimizations :
-
-O0-
No optimization (better for debugging).
-
-
-O1,-O2,-O3-
Levels of code optimization. Higher = faster, but harder to debug.
-
-
-Os-
Optimization for size (reduces executable).
-
-
-Ofast-
Aggressive optimization + relaxes IEEE standards (may affect precision).
-
-
Clang/LLVM (Low-Level Virtual Machine)
-
Focus on modularity, clear error messages.
-
High compatibility with GCC.
-
License :
-
Open-source Apache 2.0.
-
-
Platforms :
-
Windows, Linux, macOS, BSD
-
-
Debugging
-
LLDB.
-
More modern than GDB.
-
-
-
Minimum requirements :
-
Windows / Linux / macOS:
-
LLVM.
-
-
-
My version :
-
(2025-06-13) 19.1.6., x86_64-w64-windows-gnu
-
Installed at
C:/msys64/ucrt64/bin
-
-
LLVM .
-
It is not a single package but a collection of modular tools and libraries for compilation. It forms a complete compilation infrastructure, which can include multiple related components.
-
Depending on the distribution or installation method, not all components may be included.
-
Packages :
-
llvm
-
clang
-
clang-tools-extra
-
flang
-
mlir
-
lld
-
lldb
-
polly
-
libLTO
-
compiler-rt
-
libunwind
-
libc++
-
lib++abi
-
openmp
-
llvm-ar
-
llvm-nm
-
llvm-objdump
-
llvm-cov
-
llvm-profdata
-
llvm-dwarfdump
-
llvm-symbolizer
-
wasm-ld
-
-
-
The video is good, but the guy is overly enthusiastic and pro-Apple.
-
{00:00 -> 12:00}
-
In-depth conceptual explanation.
-
-
{12:00 -> 22:00}
-
ASM code and LLVM code.
-
"Sometimes using ASM directly generates slower code, due to missing compiler optimizations".
-
-
{22:00 -> end}
-
Same, repeating.
-
-
-
-
Decent, I guess.
-
Commands
-
The vast majority of all commands are exactly the same as GCC.
-
Exclusive to Clang :
-
-fcolor-diagnostics-
Displays colored errors/warnings (great for readability).
-
-
-Weverything-
Enables all warnings (even the most pedantic).
-
-
-MJ <file.json>-
Generates JSON output for analysis tools (ex: IDEs).
-
-
Opinions
-
Ginger Bill:
-
I wish I never used LLVM in the first place.
-
It has been the vast majority of the bugs in the Odin compiler.
-
It's slow as fuck, even for development builds.
-
And it gets worse with each release.
-
It's alluring because it's free and is the basis of clang.
-
MSVC (Microsoft Visual C++)
-
It is the default compiler for Visual Studio.
-
cl.exe(MSVC). -
License :
-
Microsoft proprietary.
-
-
Platforms :
-
Windows / Linux.
-
-
Languages :
-
Limited support for C11/C17
-
-
Requirements :
-
Windows:
-
Install Visual Studio (Community Edition is free).
-
Or maybe the Build Tools.
-
Honestly, you will have to download Visual Studio anyway.
-
-
-
Linux:
-
Limited support (using
clang-clor WSL).
-
-
-
My version :
-
14.42.34433 (came with Visual Studio).
-
Had to add
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.42.34433\bin\Hostx64\x64to the global PATH environment variable.
-
Commands
-
GCC or Clang equivalents :
-
.
-
-
MSVC-specific :
-
/MDvs/MT-
Chooses runtime: shared DLL (
/MD) or static (/MT).
-
-
/EHsc-
Enables C++ exceptions (default in C++ projects).
-
-
/JMC-
Supports "Just My Code" in the debugger.
-
-
/MP-
Parallel compilation (speeds up large builds).
-
-
// Equivalent to `gcc -o`
cl hello.c /Fehello.exe
// Compile with maximum warnings and debug
cl /W4 /WX /Zi hello.c /Fehello_debug.exe
// Compile with optimization (`/O2`) and C17 standard
cl /O2 /std:c17 programa.c /Feprograma_otimizado.exe
// Link with Windows libraries (e.g., `user32.lib`)
cl winapp.c /link user32.lib /Fewinapp.exe
// Compile multiple files
cl /c arquivo1.c # Generates arquivo1.obj
cl /c arquivo2.c # Generates arquivo2.obj
cl arquivo1.obj arquivo2.obj /Feprograma.exe
Windows SDK
What it includes
-
Headers and Libraries :
-
Header files ( .h ) and linking libraries ( .lib ) to access Windows APIs.
-
Examples:
-
Win32 API : To create windows, manage files, etc.
-
DirectX : For graphics and game development.
-
GDI/GDI+ : For 2D graphics.
-
COM (Component Object Model) : For reusable components.
-
-
-
Compilers :
-
Includes MSVC (Microsoft Visual C++) , used to compile native Windows code.
-
-
Debuggers and Tools :
-
Tools such as WinDbg for advanced debugging.
-
-
Resource Viewers :
-
Tools to create and edit resource files (.rc), like icons, menus, and strings.
-
-
Windows App Certification Kit :
-
Used to validate apps against Microsoft Store guidelines.
-
-
Command-Line Tools :
-
Includes utilities like:
-
rc.exe: Resource file compiler. -
mt.exe: Manifest tool. -
signtool.exe: Binary signing tool.
-
-
-
ARM64 Support :
-
Headers and libraries to compile apps for ARM devices on Windows.
-
QBE
-
https://c9x.me/compile/
-
Ginger Bill:
-
On Windows, and it's actually awful.
-
Worse than LLVM.
-
You have to generate a textual IR that you then pass to its library for it to be consumed.
-
And mainly because you cannot use it as a library whatsoever. It's designed not to be used as a library.
-
QBE is a no-go.
-
I've considered before, and no.
-